<?php
require_once("../includes/config.php");
include DIR_INCLUDES_FT.'bootstrap.php';

try {
	$conection->beginTransaction();

	$contagem = new Contagens();
	$contagem->loja_id = $_POST['loja'];
	$contagem->data_inicio = date("Y-m-d H:i:sP");
	$contagem->ficheiro_backup = time();
	$contagem->data_fim = date("Y-m-d H:i:sP");
	$contagem->save();

        $conection->commit();
	
	header("location: ".DIR_CONTAGENS_WS."contagens_form.php?id=".$contagem->id);
} catch (Exception $e) {
	$conection->rollback();
	header("location: ".DIR_WS."error_message.php?refere=".$_SERVER['HTTP_REFERER']);
}
?>